<!DOCTYPE html>
<html lang="zh-CN">
<#include "header.html">
<style type="text/css">
#BgDiv1{background-color:#000; position:absolute; z-index:9999;  display:none;left:0px; top:0px; width:100%; height:100%;opacity: 0.6; filter: alpha(opacity=60);}
.DialogDiv{position:absolute;z-index:99999;}/*配送公告*/
.U-user-login-btn{ display:block; border:none; background:url(webpages/wx/pzsw/images/bg_mb_btn1_1.png) repeat-x; font-size:1em; color:#efefef; line-height:49px; cursor:pointer; height:53px; font-weight:bold;
border-radius:3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
 width:100%; box-shadow: 0 1px 4px #cbcacf, 0 0 40px #cbcacf ;}
.U-user-login-btn:hover, .U-user-login-btn:active{ display:block; border:none; background:url(webpages/wx/pzsw/images/bg_mb_btn1_1_h.png) repeat-x; font-size:1em; color:#efefef; line-height:49px; cursor:pointer; height:53px; font-weight:bold;
border-radius:3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
 width:100%; box-shadow: 0 1px 4px #cbcacf, 0 0 40px #cbcacf ;}
.U-user-login-btn2{ display:block; border:none;background:url(webpages/wx/pzsw/images/bg_mb_btn1_1_h.png) repeat-x;   font-size:1em; color:#efefef; line-height:49px; cursor:pointer; font-weight:bold;
border-radius:3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
 width:100%; box-shadow: 0 1px 4px #cbcacf, 0 0 40px #cbcacf ;height:53px;}
.U-guodu-box { padding:5px 15px;  background:#3c3c3f; filter:alpha(opacity=90); -moz-opacity:0.9; -khtml-opacity: 0.9; opacity: 0.9;  min-heigh:200px; border-radius:10px;}
.U-guodu-box div{ color:#fff; line-height:20px; font-size:12px; margin:0px auto; height:100%; padding-top:10%; padding-bottom:10%;}

input#uploadFile{position:absolute; right:0; top:0; font-size:100px; opacity:0; filter:alpha(opacity=0);}

</style>
<body id="nextContainer" class="upload-box">
  <section class="upload-bj">
<!--      action="pzsw.action?upload&pzswId=${(pzsw.id)!}" method="post"   <div class="logo"><img class="img-responsive" src="webpages/wx/pzsw/images/logo.png"></div> -->
      <div class="index-buton">
      <form id="Form2" enctype="multipart/form-data">
			<input type="file" name="filedata" id="uploadFile" onchange="changeFile()">
			<span id="uploader" onclick="uploadFile.click();"></span>
			<input type="submit" value="上传" style="display:none;"/>
	  </form>        
      </div>
        <div class="DialogDiv"  style="display:none; ">
              <div class="U-guodu-box">
              <div>
              <table width="100%" cellpadding="0" cellspacing="0" border="0" >
                  <tr><td  align="center"><img src="webpages/wx/pzsw/images/loading.gif"></td></tr>
                  <tr><td  valign="middle" align="center" >上传中，请稍后！</td></tr>
              </table>
              </div>
      	</div>
    </section>
	<#include "footer.html">
    <script src="webpages/wx/pzsw/js/ajaxfileupload.js"></script>
	
	<script type="text/javascript">
		function AddRunningDiv() {
// 			$("#BgDiv1").css({ display: "block", height: $(document).height() });
			var yscroll = document.documentElement.scrollTop;
			var screenx=$(window).width();
			var screeny=$(window).height();
		    $(".DialogDiv").css("display", "block");
			 $(".DialogDiv").css("top",yscroll+"px");
			 var DialogDiv_width=$(".DialogDiv").width();
			 var DialogDiv_height=$(".DialogDiv").height();
			  $(".DialogDiv").css("left",(screenx/2-DialogDiv_width/2)+"px")
			 $(".DialogDiv").css("top",(screeny/2-DialogDiv_height/2)+"px")
			 $("body").css("overflow","hidden");
	    }
		
		function MoveRunningDiv() {
			$(".DialogDiv").css({ display: "none"});
        }
		
		function changeFile() {
			var uploadFile = document.getElementById("uploadFile");
// 			console.log(uploadFile);
			file = uploadFile.files[0];
// 			console.log(file);
			if (file === null || file === undefined) { 
				alert("请选择您要上传的文件！"); 
			}
			var fileName = file.name;
			var extStart=fileName.lastIndexOf(".");
			var ext=fileName.substring(extStart,fileName.length).toUpperCase();
			if(ext!=".BMP"&&ext!=".PNG"&&ext!=".GIF"&&ext!=".JPG"&&ext!=".JPEG"){
				alert("图片限于png,gif,jpeg,jpg格式");
				return;
			}
			
			var fileSize = file.size;
// 			console.log(file); 
			
			//计算文件大小 
			var size = Math.floor(fileSize/1024); 
			if (size > 1024) { 
				alert("上传文件不得超过1M!"); 
				return false; 
			}; 
			
			
			AddRunningDiv();
			$.ajaxFileUpload
            (
                {
                    url: 'pzsw.action?upload&pzswId=${(pzsw.id)!}', //用于文件上传的服务器端请求地址
                    secureuri: false, //是否需要安全协议，一般设置为false
                    fileElementId: 'uploadFile', //文件上传域的ID
                    dataType: 'JSON', //返回值类型 一般设置为json
                    success: function (data, status)  //服务器成功响应处理函数
                    {
						MoveRunningDiv();
						window.location.href='pzsw.action?page=over';
                    },
                    error: function (data, status, e)//服务器响应失败处理函数
                    {
                    	MoveRunningDiv()
                    }
                }
            )
		}
		
		jQuery.extend({
	        handleError: function (s, xhr, status, e) {
//	         	debugger;
	            if (s.error) {
	                s.error.call(s.context || s, xhr, status, e);
	            }
	            if (s.global) {
	                (s.context ? jQuery(s.context) : jQuery.event).trigger("ajaxError", [xhr, s, e]);
	            }
	        },
	        httpData: function (xhr, type, s) {
	            var ct = xhr.getResponseHeader("content-type"),
	    xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
	    data = xml ? xhr.responseXML : xhr.responseText;
	            if (xml && data.documentElement.tagName == "parsererror")
	                throw "parsererror";
	            if (s && s.dataFilter)
	                data = s.dataFilter(data, type);
	            if (typeof data === "string") {
	                if (type == "script")
	                    jQuery.globalEval(data);
	                if (type == "json")
	                    data = window["eval"]("(" + data + ")");
	            }
	            return data;
	        }
	    });
    </script>
	<script type="text/javascript">
	// 先要对监听的DOM进行一些初始化
	var hammer = new Hammer(document.getElementById("nextContainer"));
	hammer.get('swipe').set({direction:Hammer.DIRECTION_ALL});
	// 然后加入相应的回调函数即可
	hammer.on('swipeup',swipeEvent);
	hammer.on('swipedown',swipeEvent);
	
	function swipeEvent(evt) {
// 		alert(evt.type);
		if(evt.type=='swipeup') {
// 			window.location.href='pzsw.action?page=over';
		} else if(evt.type=='swipedown') {
			<#if pzsw.moduleType??&&pzsw.moduleType='bad'>
			window.location.href='pzsw.action?page=content1-5&back=1';
			<#else>
			window.location.href='pzsw.action?page=content2-5&back=1';
			</#if>
		}
	}
	</script>
</body>
</html>